package com.myportfolio.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import java.util.List;

public class AccordionPanel extends Composite implements
		Refreshable<List<AnchorViewData>> {

	private static AccordionPanelUiBinder uiBinder = GWT
			.create(AccordionPanelUiBinder.class);

	@UiField
	protected HTMLPanel accordion;

	interface AccordionPanelUiBinder extends UiBinder<Widget, AccordionPanel> {
	}

	public AccordionPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public AccordionPanel(final List<AnchorViewData> anchorViewDatas) {
		initWidget(uiBinder.createAndBindUi(this));
		refresh(anchorViewDatas);
	}

	@Override
	public void refresh(final List<AnchorViewData> viewData) {
		for (AnchorViewData anchorViewData : viewData) {
			accordion.add(new AhchorPanel(anchorViewData));
		}

	}
}
